class Solution {
public:
    vector<string> findRelativeRanks(vector<int>& score) {
        int n = score.size();
        
        vector<string> ans(score.size());

        if(n < 3)
        {
            switch(n)
            {
                case 1:
                    ans[0] = "Gold Medal";
                    break;
                case 2:
                    int pos1 = score[0] > score[1] ? 0 : 1;
                    int pos2 = !pos1;
                    ans[pos1] = "Gold Medal";
                    ans[pos2] = "Silver Medal";
                    break;
            }
            return ans;
        }

        unordered_map<int, int> mp;
        priority_queue<int> qu;
        for(int i = 0; i < score.size(); ++i)
        {
            mp[score[i]] = i;
            qu.push(score[i]);
        }
        for(int i = 0; i < 3; ++i)
        {
            int temp = qu.top();
            qu.pop();
            auto pos = mp.find(temp);
            if(pos != mp.end()) temp = pos->second;
            else break;

            switch(i)
            {
                case 0:
                    ans[temp] = "Gold Medal";
                    break;
                case 1:
                    ans[temp] = "Silver Medal";
                    break;
                case 2:
                    ans[temp] = "Bronze Medal";
                    break;
            }
        }
        for(int i = 4; i <= score.size(); ++i)
        {
            int temp = qu.top();
            qu.pop();
            auto pos = mp.find(temp);
            if(pos != mp.end()) temp = pos->second;
            
            ans[temp] =  to_string(i);
        }
        return ans;
    }
};
